﻿using DevExpress.XtraReports.UI;
using DevTeam;
using System;
namespace ConfExpert.Forms.Du4
{
    public partial class xrOrtakKumas : XtraReport
    {
        int OKRId;
        string idxs;
        public xrOrtakKumas()
        {
            InitializeComponent();
        }
        public xrOrtakKumas(string _idx, int _userId)
            : this()
        {
            MyData1.Merge(Session.DataManager.ExecuteDataSet("[GetDu4OrtakKumas]", _idx, _userId));
            MyData1.xOrtakKumasMaster.Merge(MyData1.Tables["Table"]);
            MyData1.xOrtakKumasDetail.Merge(MyData1.Tables["Table1"]);
            MyData1.xOrtakKumasDetail2.Merge(MyData1.Tables["Table2"]);


            xrOrtakKumasSub xrOrtakKumasSub1 = (xrOrtakKumasSub)xrOrtakKumasSub.ReportSource;
            xrOrtakKumasSub1.fillTables(MyData1.xOrtakKumasDetail);

            OKRId = Convert.ToInt32(MyData1.xOrtakKumasDetail2.Rows[0]["ProductId"]) - 1000000;
            idxs = _idx;
        }

        private void xrOrtakKumasSub_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            ((xrOrtakKumasSub)((XRSubreport)sender).ReportSource).PrdId.Value =
       Convert.ToInt32(GetCurrentColumnValue("ProductId"));
        }

        private void xrTable2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            xrTable2.HeightF = 268;
            Detail.HeightF = 268F;
            if (MyData1.xOrtakKumasDetail.Count > 1)
            {
                int a = MyData1.xOrtakKumasDetail.Select("ProductId=" + GetCurrentColumnValue("ProductId").ToString()).Length;
                if (a > 4)
                {
                    xrTable2.HeightF = a * 67;
                }
            }
        }

        private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            Detail.HeightF = 268F;
        }

        private void xrOrtakKumas_PrintProgress(object sender, DevExpress.XtraPrinting.PrintProgressEventArgs e)
        {
            Session.DataManager.ExecuteDataSet("UpdDu4OrtakKumasColumn", idxs, OKRId);
        }
    }
}
